<template>
	<view class="wrap">
		<scroll-view scroll-y="true" class="all" @scrolltolower="loadMore">
		<view class="wrap__store">
			<view class="store__header">
				<view class="header__item" style="overflow-x: auto;font-size: 28rpx;">{{ $t('trade.orderNum') }}</view>
				<view class="header__item">{{ $t('trade.daima') }}</view>
				<view class="item__name">
					<view class="name__text" style="overflow-x: auto;font-size: 28rpx;">{{ $t('trade.shiz') }} | {{ $t('trade.shuliang') }}</view>
					<!-- <view class="name__text"></view> -->
				</view>
				<view class="item__name">
					<view class="name__text" style="overflow-x: auto;font-size: 28rpx;">{{ $t('trade.maicj') }} | {{ $t('trade.cb') }}</view>
					<!-- <view class="name__text"></view> -->
				</view>
				<view class="header__item" style="overflow-x: auto;font-size: 28rpx;">{{ $t('trade.ccyk') }}</view>
			</view>
			<view class="store__item" v-for="(item, index) in recordsList" :key="index">
				<view class="item__name">
					<view class="name__text2" style="width: 100rpx;color: #fff;text-align: center;font-size: 28rpx;">{{item.order_num}}</view>
					<view class="name__info">
						<!-- <image class="info__icon" v-if="item.classify_id == 1"  src="@/static/icons/KRN.png"></image>
						<image class="info__icon" v-if="item.classify_id == 2"  src="@/static/icons/US.png"></image>
						<image class="info__icon" v-if="item.classify_id == 3"  src="@/static/icons/HK.png"></image> -->
						<!-- <text class="info__tag" v-if="item.product">{{item.product.zimudaima ? item.product.zimudaima.split(":")[0] : ""}}</text> -->
						<!-- <text class="info__code">{{item.product.shuzidaima}}</text> -->
					</view>
				</view>
				<view class="item__names" style="display: flex;justify-content: center;align-items: center;">
					<view class="name__info" >
						<image style="width:30rpx;height:30rpx;margin-right: 10rpx;border-radius: 50%;" class="info__icon" v-if="item.classify_id == 1"  src="@/static/icons/KRN.png"></image>
						<image style="width:30rpx;height:30rpx;margin-right: 10rpx;border-radius: 50%;" class="info__icon" v-if="item.classify_id == 2"  src="@/static/icons/US.png"></image>
						<image style="width:30rpx;height:30rpx;margin-right: 10rpx;border-radius: 50%;" class="info__icon" v-if="item.classify_id == 3"  src="@/static/icons/UK.png"></image>
					<!-- 	<text class="info__tag" v-if="item.product">{{item.product.zimudaima ? item.product.zimudaima.split(":")[0] : ""}}</text> -->
						<!-- <text class="info__code">{{item.product.shuzidaima}}</text> -->
					</view>
					<view class="name__text" style="color: #161827;font-size: 28rpx;">{{item.product.shuzidaima | padValue}}</view>
					
				</view>
				<view class="item__name">
					<view class="name__text">{{item.product.price}}</view>
					<view class="name__text">{{ item.shuliang }}</view>
				</view>
				<view class="item__name">
					<view class="name_text_change"  :class="parseFloat(item.sellprice) <parseFloat(item.price) ? 'price__total_red' : 'price__total_green'">{{item.sellprice}}</view>
					<view class="name__text">{{item.price}}</view>
				</view> 
				<view class="item__name" style="overflow-x: auto;">
					<view class="name__text" :class="parseFloat(item.yisun) > 0 ? 'price__total_red' : 'price__total_green' ">{{item.yisun}}</view>
				</view>
				<!-- <view class="item__usable">
					<view class="usable__num">{{item.product.shuzidaima}}</view>
					<text class="usable__num">{{item.shengoushuliang}}</text>
				</view> -->
			<!-- 	<view class="item__date">{{item.createtime | formatTime}}</view>
				<view :class="['item__status', 'item__status--'+ item.status]">{{item.status | formatStatus}}</view> -->
			</view>
			
		</view>
		</scroll-view>
	</view>
</template>

<script>
	import {formatDate} from '@/common/js/utils.js'
	export default{
		props:{
			recordsList:{
				type:Array,
				default:()=>([])
			}
		},
		data(){
			return {
				classify_id:0,
				type:1,
				/* recordsList:[], *///申购记录
			}
		},
		filters:{
			formatTime(timer){
				return  formatDate(timer * 1000)
			},
			formatStatus(status){
				let arr = ["申购中", "已中签", "未中签"]
				return arr[status] || "-"
			},
			padValue(value){
				if(typeof value === 'number'){
					return value.toString().padStart(5, '0')
				}
				return value
			}
		},
		onLoad() {
			// 获取申购记录
			this.getApplyRecords()
		},
		methods:{
			loadMore(){
				if(this.isLoadAll){
					uni.showToast({
						title:this.$t('empty.tips'),
						icon:"none"
					})
					return
				}
				this.pageIndex ++
				this.getTradeRecords()
			},
			async getTradeRecords(){
				uni.showLoading({
					title:this.$t('loading.loading'),
					mask:true
				})
				let {status} = this.statusList[this.statusIndex]
				let res = await this.$api.getTradeRecords(status,this.pageIndex)
				if(res.code === 1 && res.data){
					uni.hideLoading()
					this.recordsList = res.data.data
					this.totalPage = res.data.last_page
					let total = res.data.total
					if(this.recordsList.length >= total){
						this.isLoadAll= true
					}
				}
			},
			// 获取申购记录
			async getApplyRecords(){
				let res = await this.$api.getChiCangApply(this.classify_id,this.type)
				if(res && res.code === 1 && res.data){
					this.recordsList = res.data.list.data
					console.log(this.recordsList)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap{
		/* min-height: 100vh; */
		padding: 0 30rpx;
		box-sizing: border-box;
		.wrap__store{
			.store__title{
				font-size: 36rpx;
				font-weight: 800;
				color: #FFFFFF;
				@include flexRowAlign(center);
			}
			.store__header{
				margin-top: 20rpx;
				@include flexRowAlign(space-between);
				height: 64rpx;
				.item__name{
					/* @include flexCenter(column);
					align-items: flex-start; */
					text-align: center;
					width: 120rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					.name__text{
						font-size: 12rpx;
						color: #999999;
					}
					.name__info{
						@include flexRowAlign()
						margin-top: 10rpx;
						.info__tag{
							color: #fff;
							font-size: 20rpx;
							padding: 0 6rpx;
							height: 28rpx;
							background: #DE2804;
							border-radius: 6rpx;
							@include flexCenter();
						}
						.info__code{
							font-size: 20rpx;
							font-weight: 500;
							color: #FFFFFF;
							margin-left: 10rpx;
						}
						.info__icon{
							width: 30rpx;
							height: 30rpx;
							margin-right: 10rpx;
							border-radius: 50%;
						}
					}
				}
				.header__item{
					@include flexRowAlign(center);
					font-size: 28rpx;
					color: #999999;
					// width: 100rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					.item__icon{
						width: 24rpx;
						height: 28rpx;
						margin-left: 4rpx;
					}
					&:nth-child(3){
						width: 180rpx;
					}
					&:first-child{
						justify-content: flex-start;
					}
					&:last-child{
						width: 100rpx;
					}
				}
			}
			.store__item{
				@include flexRowAlign(space-between);
				height: 120rpx;
				// border-top: 1rpx solid #CCCCCC;
				.item__name{
					/* @include flexCenter(column);
					align-items: flex-start; */
					width: 120rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					.name__text{
						font-size: 28rpx;
						color:#fff;
						text-align: center;
					}
					.name__info{
						@include flexRowAlign()
						margin-top: 10rpx;
						.info__tag{
							color: #fff;
							font-size: 20rpx;
							padding: 0 6rpx;
							height: 28rpx;
							background: #DE2804;
							border-radius: 6rpx;
							@include flexCenter();
						}
						.info__code{
							font-size: 20rpx;
							font-weight: 500;
							color: #FFFFFF;
							margin-left: 10rpx;
						}
						.info__icon{
							width: 30rpx;
							height: 30rpx;
							margin-right: 10rpx;
							border-radius: 50%;
						}
					}
					.name_text_change{
						font-size: 28rpx;
						text-align: center;
						color: white;
					}
					.price__total_red{
						color:red;
					}
					.price__total_green{
						color: #2DC065;
					}
				}
				.item__usable{
					width: 160rpx;
					@include flexCenter(column);
					font-size: 26rpx;
					color: #FFFFFF;
					.usable__num{
						&:last-child{
							margin-top: 10rpx;
						}
					}
				}
				.item__date{
					@include flexCenter(column);
					text-align: center;
					font-size: 24rpx;
					color: #FFFFFF;
					width: 180rpx;
				}
				.item__status{
					@include flexCenter(column);
					width: 150rpx;
					font-size: 26rpx;
					font-weight: 800;
					color: #0369F6;
				}
				.item__status--1{
						color: #2DC065;
				}
				.item__status--2{
						color: #fff;
				}
			}
		}
	}
</style>